<template>
  <div class="btn">
    <el-row class="row-bg" justify="center">
      <el-col :span="7"
        ><el-button type="primary" size="large" @click="toEditA"
          >写 文 章</el-button
        ></el-col
      >
      <el-col :span="4"><div class="grid-content ep-bg-purple-light" /></el-col>
      <el-col :span="7"
        ><el-button type="primary" size="large" @click="toEditB"
          >提 问 题</el-button
        ></el-col
      >
    </el-row>
  </div>
</template>
    <script>
// import { checkLoginState } from "../common";
import { useUser } from "../store";
import { ElNotification } from "element-plus";
export default {
  data() {
    return {};
  },
  mounted() {},
  methods: {
    toEditA() {
      if (!this.checkLoginState()) {
        return;
      }
      this.$router.push({ path: "/article/editor" });
    },
    toEditB() {
      if (!this.checkLoginState()) {
        return;
      }
      this.$router.push({ path: "/faq/editor" });
    },
    //检查登录状态 未登录显示登录组件
    checkLoginState() {
      let userStore = useUser();
      if (sessionStorage.getItem("user") == null) {
        ElNotification({
          title: "通知",
          message: "请登录后再操作",
          type: "error",
        });

        userStore.setShowLogin(true);

        return false;
      }
      return true;
    },
  },
};
</script>
    
    <style>
.btn {
  width: 300px;
  background-color: #ffffff;
  padding: 20px;
}
</style>